package com.it.test;

import com.it.mapper.UserMapper;
import com.it.pojo.User;
import com.it.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.List;

/*
 * TODO MyBatis (3)、注解开发
 * @Insert("") 新增、@Delete("") 删除 、@Update("") 修改、@Select("") 查询、@Param("")  定义别名
 * */
public class ssm_mybatis_03 {
    SqlSession sqlSession = MyBatisUtil.SQLSession(true);
    UserMapper userMapper = sqlSession.getMapper(UserMapper.class);

    // 测试：查询年龄区间
    @Test
    public void test01() throws IOException {
        List<User> byAges = userMapper.findByAges(0, 20);
        for (User u : byAges) {
            System.out.println(u);
        }
    }

    // 测试：按性别查询
    @Test
    public void text02() {
        List<User> byGenders = userMapper.findByGenders(2);
        for (User u : byGenders) {
            System.out.println(u);
        }
    }



}
